package com.blrs.service.enterprise.electric.impl;

import java.util.List;
import java.util.Objects;

import com.blrs.service.enterprise.electric.IElectricSalesFollowRecordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.blrs.mapper.ElectricSalesFollowRecordsMapper;
import com.blrs.domain.ElectricSalesFollowRecords;

/**
 * 电销更进记录Service业务层处理
 * 
 * @author zhongliang.yang
 * @date 2023-08-15
 */
@Service
public class ElectricSalesFollowRecordsServiceImpl implements IElectricSalesFollowRecordsService
{
    @Autowired
    private ElectricSalesFollowRecordsMapper electricSalesFollowRecordsMapper;

    /**
     * 查询电销更进记录
     * 
     * @param recordsId 电销更进记录主键
     * @return 电销更进记录
     */
    @Override
    public ElectricSalesFollowRecords selectElectricSalesFollowRecordsByRecordsId(String recordsId)
    {
        return electricSalesFollowRecordsMapper.selectElectricSalesFollowRecordsByRecordsId(recordsId);
    }

    /**
     * 查询电销更进记录列表
     * 
     * @param electricSalesFollowRecords 电销更进记录
     * @return 电销更进记录
     */
    @Override
    public List<ElectricSalesFollowRecords> selectElectricSalesFollowRecordsList(ElectricSalesFollowRecords electricSalesFollowRecords)
    {

        return electricSalesFollowRecordsMapper.selectElectricSalesFollowRecordsList(electricSalesFollowRecords);
    }

    /**
     * 新增电销更进记录
     * 
     * @param electricSalesFollowRecords 电销更进记录
     * @return 结果
     */
    @Override
    public int insertElectricSalesFollowRecords(ElectricSalesFollowRecords electricSalesFollowRecords)
    {
        //查询这条数据携带的主键是否存在与数据库,如果存在说明修改操作

        if (Objects.isNull(electricSalesFollowRecordsMapper.selectElectricSalesFollowRecordsByRecordsId(electricSalesFollowRecords.getRecordsId()))){
        return     electricSalesFollowRecordsMapper.insertElectricSalesFollowRecords(electricSalesFollowRecords);
        }else {
            return electricSalesFollowRecordsMapper.updateElectricSalesFollowRecords(electricSalesFollowRecords);
        }

    }

    /**
     * 修改电销更进记录
     * 
     * @param electricSalesFollowRecords 电销更进记录
     * @return 结果
     */
    @Override
    public int updateElectricSalesFollowRecords(ElectricSalesFollowRecords electricSalesFollowRecords)
    {
        return electricSalesFollowRecordsMapper.updateElectricSalesFollowRecords(electricSalesFollowRecords);
    }

    /**
     * 批量删除电销更进记录
     * 
     * @param recordsIds 需要删除的电销更进记录主键
     * @return 结果
     */
    @Override
    public int deleteElectricSalesFollowRecordsByRecordsIds(String[] recordsIds)
    {
        return electricSalesFollowRecordsMapper.deleteElectricSalesFollowRecordsByRecordsIds(recordsIds);
    }

    /**
     * 删除电销更进记录信息
     * 
     * @param recordsId 电销更进记录主键
     * @return 结果
     */
    @Override
    public int deleteElectricSalesFollowRecordsByRecordsId(String recordsId)
    {
        return electricSalesFollowRecordsMapper.deleteElectricSalesFollowRecordsByRecordsId(recordsId);
    }
}
